<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="app">

    <form v-on:submit.prevent="addNewTodo">
        <label for="new-todo">Add a todo</label>
        <input
                v-model="newTodoText"
                id="new-todo"
                placeholder="E.g. Feed the cat"
        >
        <button>Add</button>
    </form>


    <ul>
        <li
                is="todo-item"
                v-for="(todo, index) in todos"
                v-bind:key="todo.id"
                v-bind:title="todo.title"
                v-on:remove="remove"

        ></li>
    </ul>

    <div >
        <input type="radio" id="one" value="One" v-model="picked">
        <label for="one">One</label>
        <br>
        <input type="radio" id="two" value="Two" v-model="picked">
        <label for="two">Two</label>
        <br>
        <span>Picked: {{ picked }}</span>

        <!-- `toggle` 为 true 或 false -->
        <input type="checkbox" v-model="toggle"  true-value="yes"
               false-value="no">

        <span>{{toggle}}</span>
    </div>

    <div id="example-5">
        <select v-model="selected">
            <option disabled value="">请选择</option>
            <option value="123">A</option>
            <option value="456">B</option>
            <option value="789">C</option>
        </select>
        <span>Selected: {{ selected }}</span>
    </div>

</div>


















<template id="btn">
    <div>
        <ul>
            <li v-for="n in evenNumbers">{{ n }}</li>
        </ul>


        <ul v-for="set in sets">
            <li v-for="n in even(set)">{{n}}</li>
        </ul>

        <template v-for="item in apples">
            <li>{{ item }}</li>
            <li class="divider" role="presentation"></li>
        </template>

    </div>


</template>
<script src="../js/vue.js"></script>
<script src="../js/axios.js"></script>
<script>


    Vue.component('todo-item', {
        template: '\
    <li>\
      {{ title }}\
      <button v-on:click="$emit(\'remove\',$event.target.tagName)">Remove</button>\
    </li>\
  ',
        props: ['title']
    })


    const btn = {
        template: "#btn",
        data() {
            return {
                numbers: [1, 2, 3, 4, 5],
                sets: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]],
                apples: ['a', 'b', 'c', 'd'],
                picked:''
            }

        },
        computed: {
            evenNumbers: function () {
                return this.numbers.filter(function (number) {
                    return number % 2 === 0
                })
            }
        },
        methods: {
            even: function (numbers) {
                return numbers.filter(function (number) {
                    return number % 2 === 0
                })
            }

        }
    };
    const vm = new Vue({
        el: "#app",
        data: {
            message: "hello vue",
            title: "fa",
            apples: [1, 2, 3, 4],
            newTodoText: '',
            selected:'',
            toggle:'',
            todos: [
                {
                    id: 1,
                    title: 'Do the dishes',
                },
                {
                    id: 2,
                    title: 'Take out the trash',
                },
                {
                    id: 3,
                    title: 'Mow the lawn'
                }
            ],
            nextTodoId: 4,
            picked:''
        },
        components: {
            btn: btn
        },
        created: function () {

        },
        mounted: function () {

        },
        methods: {
            remove(event){

                console.log(event)
            }

        },
        computed: {}
    })




</script>
</body>
</html>
